package com.jiahe.video.context;


import com.jiahe.video.model.GroupInfo;
import com.jiahe.video.model.TokenInfo;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * App上下文，单例模式
 */
@Data
public class AppContent {

    // 用户token
    private TokenInfo tokenInfo;

    private Map<String, GroupInfo> groupInfoMap;

    private AppContent(){}

    private static AppContent appContent;

    public static synchronized AppContent getAppContent() {
        if (appContent == null) {
            appContent = new AppContent();
        }
        return appContent;
    }

    public Map<String, GroupInfo> getGroupInfoMap() {
        this.groupInfoMap = groupInfoMap==null?new HashMap<>() :groupInfoMap;
        return groupInfoMap;
    }

}
